#include "noteitem.h"
#include "ui_noteitem.h"

NoteItem::NoteItem(QListWidgetItem *pItem,QWidget *parent) :
    QWidget(parent),
    ui(new Ui::NoteItem),
    m_pItem(pItem)
{
    ui->setupUi(this);
    ui->DelPushButton->setIcon(QIcon(":/Icon/del.ico"));
    ui->DelPushButton->setIconSize(QSize(32,32));

    ui->AlarmPushButton->setIcon(QIcon(":/Icon/Alarm.ico"));
    ui->AlarmPushButton->setIconSize(QSize(32,32));
    //每创建一个Item，新建一个Alarm
    m_pAlarm = new AlarmSetting();
    connect(m_pAlarm, SIGNAL(AlarmEnterSignal(int,int,int,QString,QString,QString)),this,SLOT(AlarmSettingSlot(int,int,int,QString,QString,QString)));
}

NoteItem::NoteItem(QListWidgetItem *pItem, QString t_Month, QString t_Day, QString t_Week, QString t_MettingTime, QString t_MettingAddr, QString t_EventContent,QWidget *parent):
    m_pItem(pItem),
    Month(t_Month.toInt()),
    Day(t_Day.toInt()),
    Week(t_Week.toInt()),
    MettingTime(t_MettingTime),
    MettingAddr(t_MettingAddr),
    EventContent(t_EventContent),
    QWidget(parent),
    ui(new Ui::NoteItem)
{
    ui->setupUi(this);

    ui->DelPushButton->setIcon(QIcon(":/Icon/del.ico"));
    ui->DelPushButton->setIconSize(QSize(32,32));

    ui->AlarmPushButton->setIcon(QIcon(":/Icon/Alarm.ico"));
    ui->AlarmPushButton->setIconSize(QSize(32,32));
    //每创建一个Item，新建一个Alarm
    m_pAlarm = new AlarmSetting(Month,Day,Week,MettingAddr,MettingTime,EventContent);
    connect(m_pAlarm, SIGNAL(AlarmEnterSignal(int,int,int,QString,QString,QString)),this,SLOT(AlarmSettingSlot(int,int,int,QString,QString,QString)));

    ui->NoteItemLabel->setText(EventContent);
}

NoteItem::~NoteItem()
{
    delete ui;
}

void NoteItem::AlarmSettingSlot(int calendarMonth, int calendarDay, int calendarWeek, QString MettingTime, QString MettingAddr, QString EventContent)
{
    Month = calendarMonth;
    Day = calendarDay;
    Week = calendarWeek;

    MettingTime = MettingTime;
    MettingAddr = MettingAddr;
    EventContent= EventContent;

    AlarmSettingEnterSignals(Month,Day,Week,MettingTime,MettingAddr,EventContent);
    ui->NoteItemLabel->setText(EventContent);
}

//垃圾桶按钮槽函数
void NoteItem::on_DelPushButton_clicked()
{
    NoteItemDelSignal(m_pItem);//发送删除信号
}

//闹钟按钮槽函数
void NoteItem::on_AlarmPushButton_clicked()
{    
    AlarmSettingPushSignals(m_pItem);//闹钟按钮按下
    m_pAlarm->show();
}


void NoteItem::on_NoteItemRadioButton_clicked(bool checked)
{
    QFont font;
    if (checked)
    {
        ui->NoteItemLabel->setStyleSheet("color:red");//红色
        font.setStrikeOut(true);
    }
    else
    {
        ui->NoteItemLabel->setStyleSheet("color:black");//红色
        font.setStrikeOut(false);
    }
    ui->NoteItemLabel->setFont(font);
}
